package com.example.demo.common;

import com.example.demo.entity.Userinfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/*
当前登陆用户相关操作
 */
public class UserSessionUtils {
    //得到当前登陆用户
    public static Userinfo getSessionUser(HttpServletRequest request){
        HttpSession session=request.getSession(false);
        if(session!=null && session.getAttribute(AppVariable.USER_SESSION_KEY)!=null){
            //用户已登陆
            return (Userinfo)session.getAttribute(AppVariable.USER_SESSION_KEY);
        }
        return null;
    }
}
